// Learn TypeScript:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

import FacebookPlayerInfoInRank from "../Facebook/FacebookPlayerInfoInRank";
import MsgSystem from "../MsgSystem/MsgSystem";
import MsgDefine from "../MsgSystem/MsgDefine";

export default class RankManager extends cc.EventTarget {
    private static _instance = null;

    private globalRankList: Array<FacebookPlayerInfoInRank> = new Array<FacebookPlayerInfoInRank>();//全球排行榜
    private friendRankList: Array<FacebookPlayerInfoInRank> = new Array<FacebookPlayerInfoInRank>();//好友排行榜

    public static getInstance(): RankManager {
        if (!RankManager._instance) {
            RankManager._instance = new RankManager();
        }
        return RankManager._instance;
    }

    public setGlobalRankList(rank: Array<FacebookPlayerInfoInRank>) {
        this.globalRankList = rank;
        MsgSystem.GetInstance().PostMsg(MsgDefine.rankLoadFinish,rank);
    }

    public setFriendRankList(rank: Array<FacebookPlayerInfoInRank>) {
        this.friendRankList = rank;
        MsgSystem.GetInstance().PostMsg(MsgDefine.rankLoadFinish,rank);
    }

    public getGlobalRankList(): Array<FacebookPlayerInfoInRank> {
        return this.globalRankList;
    }

    public getFriendRankList(): Array<FacebookPlayerInfoInRank> {
        return this.friendRankList;
    }

}
